﻿using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Swork03_28.Api.Application.Commands.FarmedCommand;
using Swork03_28.Domain.TraceableInfos;

namespace Swork03_28.Api.Controllers
{
    /// <summary>
    /// 养殖控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]
    public class FarmedsController : ControllerBase
    {
        private readonly IMediator mediator;

        public FarmedsController(IMediator mediator)
        {
            this.mediator = mediator;
        }


        /// <summary>
        /// 添加养殖信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> CraeteFarmed(FarmedCreateCommand command)
        {
            return await mediator.Send(command);
        }


        /// <summary>
        /// 获取养殖信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<Farmed>> GetFarmeds([FromQuery] FarmedSelectCommand command)
        {
            return await mediator.Send(command);
        }

        /// <summary>
        /// 获取疫苗信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<Vaccine>> GetVaccine([FromQuery] VIccineSelectCommand command)
        {
            var info = await mediator.Send(command);
            return info;
        }

        /// <summary>
        /// 添加动检证
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> CreateCertificate(VaccineCreateCertificateImgCommand command)
        {
            return await mediator.Send(command);
        }

        /// <summary>
        /// 删除动检证
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<int> DelVaccine([FromQuery] VaccineDelImgCommand command)
        {
            return await mediator.Send(command);
        }


        /// <summary>
        /// 添加养殖公司信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> CreateFirm(FirmCreateCommand command)
        {
            return await mediator.Send(command);
        }

        /// <summary>
        /// 获取公司信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<FirmInfo> GetFirmInfo([FromQuery] FirmSelectCommand command)
        {
            return await mediator.Send(command);
        }

        /// <summary>
        /// 添加公司图片
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> FilmImgCreate(FirmImgCreateCommand command)
        {
            return await mediator.Send<int>(command);
        }

        /// <summary>
        /// 删除企业图片
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<int> FirmImgDel([FromQuery] FirmImgDelCommand command)
        {
            return await mediator.Send(command);
        }

        /// <summary>
        /// 添加保健信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> HealthCreate(HealthCreateCommand command)
        {
            return await mediator.Send(command);
        }


        /// <summary>
        /// 添加保健信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<int> HealthUpdate(HealthUpdateCommand command)
        {
            return await mediator.Send(command);
        }

        /// <summary>
        /// 删除保健信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<int> HealthDelete([FromQuery]HealthDeleteCommand command)
        {
            return await mediator.Send(command);
        }
    }
}
